package com.lgs.demo.ui;

import android.content.Context;

import com.lgs.demo.R;
import com.lgs.demo.base.BaseHolder;
import com.lgs.demo.base.BaseLazyFragment;
import com.lgs.demo.base.MySuperBaseAdapter;
import com.lgs.demo.bean.MarkBean;
import com.lgs.demo.bean.MarketHolder;
import com.lgs.demo.customview.PagerListView;

import java.util.ArrayList;

import butterknife.BindView;

/**
 * Created by lgs on 2018/3/10.
 */

public class BTCPagerFragment extends BaseLazyFragment {

    @BindView(R.id.listView)
    PagerListView mListView;
    private ArrayList<MarkBean> datas;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_btc;
    }

    @Override
    protected void init() {
        super.init();

        NewActivity.PagerInfo[] values = NewActivity.PagerInfo.values();
        if (null != values) {
            for (int i = 0; i < values.length; i++) {
                mListView.setViewPager(values[i].getViewPager());
            }
        }
        /*if (null != values) {
            LogUtil.i("values" + values.length);
            ViewPager viewPager = values[0].getViewPager();
            mListView.setViewPager();
            LogUtil.i("viewPager ====== " + viewPager);
        }*/
        initData();
    }

    private void initData() {
        datas = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            MarkBean markBean = new MarkBean();
            markBean.setVolumeName("BTC");
            markBean.setVolumeNum(100);
            markBean.setNewPrice(100.00);
            markBean.setVolumePrice(110.00);
            markBean.setRose("100.00%");
            datas.add(markBean);
        }
        mListView.setAdapter(new MyAdapter(datas));
    }

    private class MyAdapter extends MySuperBaseAdapter {

        public MyAdapter(ArrayList datas) {
            super(datas);
        }

        @Override
        protected BaseHolder getHolder(Context context) {
            return new MarketHolder(context);
        }
    }
}
